<template>
	<view class="content">
		<view class="header-box">
			<view class="price">￥{{total_price}}</view>
			<view class="fenhong">已分红(元)</view>
		</view>
		<view class="group-line">
			分红记录
		</view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view class="histry-list">
				<view class="histry-item" v-for="(item, index) in tabList" :key="index">
					<view class="">
						<view style="color: #F55454;">{{item.team_level_name}}</view>
						<view>{{item.created_at}}</view>
					</view>
					<view class="right" style="color: #F55454;">￥{{item.amount}}</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				orderPrams: {
					page: 1,
				},
				tabList: [],
				total_price: 0
			};
		},
		onShow() {
			this.downCallback();
		},
		methods:{
			// 下拉刷新列表
			downCallback() {
				this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
			},
			/*上拉加载的回调*/
			upCallback(page) {
				this.orderPrams.page = page.num;
				this.$http.get('user.fehhonglist', this.orderPrams).then(res => {
					this.total_price = res.data.total_price
					let curPageData = res.data.data;
					let curPageLen = curPageData.length;
					let totalCount = res.data.total;
					if (page.num == 1) this.tabList = []; //如果是第一页需手动置空列表
					this.tabList = this.tabList.concat(curPageData); //追加新数据
					this.mescroll.endBySize(curPageLen, totalCount);
				})
			},
		}
	}
</script>

<style lang="scss">
	@import './fenhong-histry.scss';
</style>
